[][src]Crate paths_as_strings

Functions

decode_path

Reverses the encoding of a Path performed by encode_path. This function should always be used to reverse the encoding, as it will correctly detect whether the string 'S' is an actual path or one that was Base-64 encoded. The function will only return an error if the Path was the Base-64 encoded form and the encoding has been tampered with.

encode_path

Converts the Path P to a UTF-8 string which can be safely written to a file irrespective of whether the original Path contains unprintable characters or is an invalid UTF-8 string. If the Path is a valid UTF-8 string and contains no control characters such as \t it is returned as-is, otherwise it is encoded as a Base-64 string and given a special prefix which means the resultant string can be unambiguously detected as an encoded path rather than an actual path. This conversion can be reversed using the decode_path function.